﻿/**************************************************************

项目名称 :ThinkWide数据访问基础库
版权所有 (c) 2010 ThinkWide
+-------------------------------------------------------------
项目: MFDataParameter数据库服务类


版本: 1


创建日期:2010-8-3


作者: 章称

+-------------------------------------------------------------
描述:z

更新:   2010-8-3

ToDo:

***************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Runtime.Serialization;

namespace MF.Data.SupplyInterface
{
    [Serializable]
    [DataContract]
    public class MFDataParameter: IDataParameter
    {
        [DataMember]
        public DbType DbType { get; set; }
        [DataMember]
        public int Size { get; set; }
        [DataMember]
        public ParameterDirection Direction { get; set; }
        [DataMember]
        public bool IsNullable { get; set; }
        [DataMember]
        public string ParameterName { get; set; }
        [DataMember]
        public string SourceColumn { get; set; }

        public DataRowVersion SourceVersion { get; set; }
        [DataMember]
        public object Value { get; set; }

        public bool Assign(IDataParameter dataParameter)
        {
            dataParameter.DbType = DbType;
            dataParameter.Direction = Direction;

            dataParameter.ParameterName = ParameterName;
            dataParameter.SourceColumn = SourceColumn;
            //if ((int)dataParameter.SourceVersion!=0) dataParameter.SourceVersion = SourceVersion;  //wcf don't support DataRowVersion

            dataParameter.Value = Value;
            return true;
        }

    }

    [Serializable]
    public class MFDataParameters:List<MFDataParameter>
    {
        public MFDataParameter this[string name]
        {
            get
            {
                foreach (MFDataParameter item in this)
                {
                    if (String.Equals(item.ParameterName,name,StringComparison.OrdinalIgnoreCase))
                    {
                        return item;
                    }
                }
                return null;
                
            }

        }
    }
}
